package com.wyman.aop.aspectj;

import com.wyman.aop.Pointcut;
import com.wyman.aop.PointcutAdvisor;
import org.aopalliance.aop.Advice;

/**
 * @Author 李伟民
 * @Description
 * @DateTime 2024/12/29 00:06
 */
//目的是绑定 aop和方法之间的对应关系 即实现的aop逻辑应该映射到哪些类 哪些方法
public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {

    private AspectJExpressionPointcut pointcut;

    //advice是拦截器 即MethodBeforeAdviceInterceptor
    private Advice advice;

    private String expression;


    public void setExpression(String expression){
        this.expression = expression;
    }

    @Override
    public Pointcut getPointcut() {
        if(null==pointcut) {
            pointcut = new AspectJExpressionPointcut(expression);
        }
        return pointcut;
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

    public void setAdvice(Advice advice) {
        this.advice = advice;
    }
}
